var app = getApp()
var $ = require("../../utils/httpHelper.js")
Page({
  data: {
    page: 1,
    pagesize: 5,
    totalpage: 0,//最大页数
    nomore: true,
    objarr:[]
  },
  
  onLoad: function (options) {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({ height: res.windowHeight })
      }
    })
    let params = {
      rd_session: app.globalData.userInfo.rd_session,
      page:this.data.page,
      page_size:this.data.pagesize
    }
    $.httpPost("teacher_list", params, (data, err) => {
      this.setData({
        objarr:data.data.list
      })
    })
  },

  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        rd_session: app.globalData.userInfo.rd_session,
        page: this.data.page,
        pagesize: this.data.pagesize,
      }
      $.httpPost("teacher_list", params, (data, err) => {
        let arr = this.data.objarr;
        for (let item of data.data.list) {
          arr.push(item);
        }
        this.setData({
          objarr: arr
        })
      })
    }
  },
  todetail(e){
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/about/t_detail?id='+id
    })
  }
})
